<template>
  <el-aside width="200px" class="aside">
    <el-menu
      :default-active="activePath"
      exact
      class="el-menu-vertical-demo"
      router
      background-color="#545c64"
      text-color="#fff"
      active-text-color="#ffd04b"
    >
      <div class="logo-container">
        <img src="../assets/logo1.png" class="logo-image" />
        <p class="logo-text">比赛信息管理平台</p>
      </div>
      <NavItem
        v-for="item in menuItems"
        :key="item.url"
        :item="item"
        :basePath="item.url"
      />
    </el-menu>
  </el-aside>
</template>

<script>
import NavItem from "./NavItem.vue";

export default {
  name: "navMenu",
  props:{
    menuItems:{
      type: Array,
      default: function() {
        return [];
      }
    }
  },
  components: {
    NavItem,
  },
  computed: {
    activePath() {
      // 当路径包含 "/home/competition" 时，返回父路径激活
      return this.$route.path.includes('/home/competition') 
        ? '/home/competition' 
        : this.$route.path;
    }
  },
  data() {
    return {
      logoTextShow: true
    };
  },
};
</script>

<style scoped lang="scss">
.aside {
  .el-menu-vertical-demo {
    min-height: 100vh;
    border-right: none;
  }

  .logo-container {
    height: 170px;
    // line-height: 150px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    .logo-image {
      width: 30px;
      margin-right: 10px;
      margin-top: 50px;
      margin-bottom: 15px;
    }

    .logo-text {
      color: white;
      margin-bottom: 40px;
      font-size: 16px;
      font-weight: 500;
    }
  }
}
</style>
